﻿using System;
using System.Collections.Generic;
using System.Security.AccessControl;
using System.Text;
using Microsoft.Extensions.FileProviders;

namespace Web.Core.Infrastructure
{
    public interface ISwFileProvider : IFileProvider
    {
        string Combine(params string[] paths);
        void CreateDirectory(string path);
        void CreateFile(string path);
        /// <summary>
        /// 递归删除
        /// </summary>
        /// <param name="path"></param>
        void DeleteDirectory(string path);
        /// <summary>
        /// 删除指定文件
        /// </summary>
        /// <param name="filePath">不支持通配符</param>
        void DeleteFile(string filePath);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        bool DirectoryExists(string path);
        void DirectoryMove(string sourceDirName, string destDirName);
        /// <summary>
        /// 获取指定目录下文件 支持通配符
        /// </summary>
        /// <param name="directoryPath"></param>
        /// <param name="searchPattern"></param>
        /// <param name="topDirectoryOnly"></param>
        /// <returns></returns>
        IEnumerable<string> EnumerateFiles(string directoryPath, string searchPattern, bool topDirectoryOnly = true);
        /// <summary>
        /// 拷贝一个已存在的文件为新的文件 
        /// </summary>
        /// <param name="sourceFileName"></param>
        /// <param name="destFileName"></param>
        /// <param name="overwrite"></param>
        void FileCopy(string sourceFileName, string destFileName, bool overwrite = false);
        bool FileExists(string filePath);
        long FileLength(string path);
        void FileMove(string sourceFileName, string destFileName);
        string GetAbsolutePath(params string[] paths);
        DirectorySecurity GetAccessControl(string path);
        DateTime GetCreationTime(string path);
        string[] GetDirectories(string path, string searchPattern = "", bool topDirectoryOnly = true);
        string GetDirectoryName(string path);
        string GetDirectoryNameOnly(string path);
        string GetFileExtension(string filePath);
        string GetFileName(string path);
        string GetFileNameWithoutExtension(string filePath);
        string[] GetFiles(string directoryPath, string searchPattern = "", bool topDirectoryOnly = true);
        DateTime GetLastAccessTime(string path);
        DateTime GetLastWriteTime(string path);
        DateTime GetLastWriteTimeUtc(string path);
        string GetParentDirectory(string directoryPath);
        string GetVirtualPath(string path);
        bool IsDirectory(string path);
        /// <summary>
        /// 虚拟目录到物理目录处理
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        string MapPath(string path);
        byte[] ReadAllBytes(string filePath);
        string ReadAllText(string path, Encoding encoding);
        void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
        void WriteAllBytes(string filePath, byte[] bytes);
        void WriteAllText(string path, string contents, Encoding encoding);
    }
}
